package com.atguigu.tingshu.config;

import com.atguigu.tingshu.common.rabbit.constant.MqConst;
import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

import java.util.HashMap;

@Configuration
public class OrderCancelConfig {

    @Bean
    public CustomExchange delayedExchange() {

        HashMap<String, Object> map = new HashMap<>();
        map.put("x-delayed-type","direct");

        return new CustomExchange(MqConst.EXCHANGE_CANCEL_ORDER,"x-delayed-message",true,false,map);
    }
    @Bean
    public Queue delayQueue(){
        return new Queue(MqConst.QUEUE_CANCEL_ORDER,true,false,false);
    }

    @Bean
    public Binding delayBinding(){
        return BindingBuilder.bind(delayQueue()).to(delayedExchange()).with(MqConst.ROUTING_CANCEL_ORDER).noargs();
    }




}
